<template>
	<view class="cent">
		<view class="banldeyail">
			<view style="color: #4A4A4A;font-size: 16px;margin-left: 20px;">
				<view style="margin-top: 20px;">银行名称：{{ list.bankname }}</view>
				<view style="margin-top: 20px;">持卡人姓名：{{ list.bankusername }}</view>
				<view style="margin-top: 20px;">银行卡号：{{ list.bankid }}</view>
			</view>
			<image src="../../static/img/bge_chs.png" mode="" style="width: 87px;height: 42px;margin-top: 10px;" v-if="list.status == 0"></image>
			<image src="../../static/img/bge_ch.png" mode="" style="width: 87px;height: 42px;margin-top: 10px;" v-if="list.status == 1"></image>
		</view>
		<view class="banked">
			<view style="font-size: 16px;color: #4A4A4A;margin-left: 20px;">
				应收金额
			</view>
			<view style="font-size: 18px;color: #FE0700;margin-right: 15px;" >
				{{money}}
			</view>
		</view>
		<view class="banked">					<view style="font-size: 16px;color: #4A4A4A;margin-left: 20px;">						实收金额					</view>					<view style="font-size: 18px;color: #FE0700;margin-right: 15px;" >						{{moned}}					</view>
				</view>
		<button v-if="list.status == 0" @click="stop">停用</button>
		<button v-if="list.status == 1"  @click="start">启用</button>
	</view>
</template>

<script>
	import {ajaxs} from "../../captainapi.js"
export default {
	data() {
		return {
			list: [],
			money:0,
			moned:0,
		};
	},
	onLoad(option) {
		this.list = option;
		var that=this
		ajaxs({
			url:"/v1/order/manager/money",
			method:"post",
			data:{
				contactBankNo:option.bankusername,
			},
			success(res){
				if(res.data.message.acceptedMoney==null){
					that.moned=0
				}else{
					that.moned=res.data.message.acceptedMoney
				}
				if(res.data.message.receivableMoney==null){
					that.money=0
				}else{
					that.money=res.data.message.receivableMoney
				}
			}
		})
	},
	methods: {
		stop() {
			var that=this
			uni.showModal({
				content: '请您确认是否停用该结算卡？',

				success: function(res) {
					if (res.confirm) {
						//这里是点击了确定以后
						ajaxs({
							url: '/v1/user/bankCard/update',
							method: 'post',
							data: {
								id:that.list.id,
								status:1,
							},
							success(res) {
								if (res.data.status == 'OK') {
									uni.navigateBack({
										delta: 1
									});
								} else {
									uni.showToast({
										title: res.data.message, // 标题
										icon: 'none'
									});
								}
							}
						});
					} else {
						//这里是点击了取消以后
					}
				}
			});
		},
		// 启用
		start() {
			var that=this
			uni.showModal({
				content: '请您确认是否启用该结算卡？',
		
				success: function(res) {
					if (res.confirm) {
						//这里是点击了确定以后
						ajaxs({
							url: '/v1/user/bankCard/update',
							method: 'post',
							data: {
								id:that.list.id,
								status: 0,
							},
							success(res) {
								if (res.data.status == 'OK') {
									uni.navigateBack({
										delta: 1
									});
								} else {
									uni.showToast({
										title: res.data.message, // 标题
										icon: 'none'
									});
								}
							}
						});
					} else {
						//这里是点击了取消以后
					}
				}
			});
		}
	}
};
</script>

<style>
	.banked{
		width:355px;
		height:56px;
		background:rgba(255,255,255,1);
		border-radius:8px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 10px;
	}
.banldeyail {
	width: 355px;
	height: 148px;
	background: rgba(255, 255, 255, 1);
	border-radius: 8px;
	margin-top: 10px;
	display: flex;
	justify-content: space-between;
}
page {
	height: 100%;
}
button {
	width: 355px;
	height: 44px;
	background: rgba(4, 42, 88, 1);
	border-radius: 8px;
	margin-top: 235px;
	color: #ffffff;
}
</style>
